<?php

class wsGetUserInfos
{

    /**
     *
     * @param string $name            
     * @return wsGetUserInfosResult
     */
    public function getUserInfos ($name)
    {
        $details = new detailsBrotherList();
        $details->addBrotherDetail(new brotherDetail("Jean", 1, 10));
        $details->addBrotherDetail(new brotherDetail("Jack", 2, 20));
        $details->addBrotherDetail(new brotherDetail("Martin", 3, 30));
        
        $tmp = new wsGetUserInfosResult("Etienne", "Dupont", 33, $details);
        
        return objectToArray($tmp);
    }
}

function objectToArray ($d)
{
    if (is_object($d)) {
        // Gets the properties of the given object
        // with get_object_vars function
        $d = get_object_vars($d);
    }
    if (is_array($d)) {
        /*
         * Return array converted to object Using __FUNCTION__ (Magic constant) for recursive call
         */
        return array_map(__FUNCTION__, $d);
    } else {
        // Return array
        return $d;
    }
}

/**
 * @xsd sequence
 */
class wsGetUserInfosResult
{

    /**
     * @xsd sequence start
     *
     * @var string
     */
    public $firstName;

    /**
     *
     * @var string
     */
    public $familyName;

    /**
     *
     * @var AgeType
     */
    public $age;

    /**
     *
     * @var detailsBrotherList @xsd sequence end
     */
    public $detailsBrotherList;

    /**
     *
     * @param string $firstName            
     * @param string $familyName            
     * @param integer $age            
     * @param detailsBrotherList $detailsBrotherList            
     * @return wsGetUserInfosResult
     */
    public function __construct ($firstName, $familyName, $age, $detailsBrotherList)
    {
        $this->firstName = $firstName;
        $this->familyName = $familyName;
        $this->age = $age;
        $this->detailsBrotherList = $detailsBrotherList;
        
        return $this;
    }
}

/**
 * @xsd simpleType array('id' => 1)
 * @xsd restriction array('base' => 'xsd:string')
 */
class AgeType
{

    /**
     * @xsd pattern array('value' => '[0-9][0-9][0-9]')
     */
    public $pattern;
}

/**
 * @xsd simpleType
 * @xsd restriction array('base' => 'xsd:string')
 */
class RankType
{

    /**
     * @xsd enumeration array('value' => '1')
     * @xsd enumeration array('value' => '2')
     * @xsd enumeration array('value' => '3')
     */
    public $enumeration;
}

/**
 * @xsd sequence
 * @xsd complexType
 */
class detailsBrotherList
{

    /**
     *
     * @var brotherDetail array('minOccurs'=>0, 'maxOccurs'=>"unbounded")
     */
    public $brotherDetail;

    /**
     *
     * @return detailsBrotherList
     */
    public function __construct ()
    {
        $this->brotherDetail = array();
        return $this;
    }

    /**
     *
     * @param brotherDetail $brotherDetail            
     */
    public function addBrotherDetail ($brotherDetail)
    {
        $this->brotherDetail[] = $brotherDetail;
    }
}

/**
 * @xsd sequence array('id' => 3)
 * @xsd complexType array('id' => 2)
 */
class brotherDetail
{

    /**
     *
     * @var string
     */
    public $firstName;

    /**
     *
     * @var RankType
     */
    public $rank;

    /**
     *
     * @var AgeType
     */
    public $age;

    /**
     *
     * @param string $firstName            
     * @param RankType $rank            
     * @param AgeType $age            
     * @return brotherDetail
     */
    public function __construct ($firstName, $rank, $age)
    {
        $this->firstName = $firstName;
        $this->rank = $rank;
        $this->age = $age;
        
        return $this;
    }
}